package cn.itcast.web;


import cn.itcast.pojo.User;
import cn.itcast.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;


/*
数据库事务Xml配置
多属性
@Controller
public class HelloController {
    @GetMapping("hello")
    @ResponseBody
    public String Hello(){
        return "Hello, Spring Boot!";
    }
}
*/

@Slf4j
@RestController
@RequestMapping("user")
public class HelloController {

    @Autowired
    private UserService userService;
//    @Autowired
//    private DataSource dataSource;
    @GetMapping("{id}")
//    @ResponseBody
    public User Hello(@PathVariable("id") Long id) {
//      使用@Slf4j注解 Lombok自动生成log
    /*    log.debug("hello method is running");
        System.out.println("hello method is running");
        return "Hello, Spring Boot!";*/
        return userService.QueryById(id);
    }
}